/*
 * DropClientView.java
 */

package dropclient;

import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Component;
import java.awt.GridLayout;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.Socket;
import java.net.URL;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollBar;
import javax.swing.ScrollPaneLayout;

/**
 * The application's main frame.
 */
public class DropClientView extends FrameView {
   

    public DropClientView(SingleFrameApplication app) {
        super(app);

        initComponents();
        HideHome();
        /*folderlabel.setVisible(false);
        foldernamefield.setVisible(false);
        browseBtn.setVisible(false);
        syncBtn.setVisible(false);
        logoutBtn.setVisible(false);
        filepanel.setVisible(false);
        addressField.setVisible(false);
        serverLabel.setVisible(false);*/

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = DropClientApp.getApplication().getMainFrame();
            aboutBox = new DropClientAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        DropClientApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        unamelabel = new javax.swing.JLabel();
        upasslabel = new javax.swing.JLabel();
        unamefield = new javax.swing.JTextField();
        loginBtn = new javax.swing.JButton();
        upassfield = new javax.swing.JPasswordField();
        folderlabel = new javax.swing.JLabel();
        foldernamefield = new javax.swing.JTextField();
        browseBtn = new javax.swing.JButton();
        syncBtn = new javax.swing.JButton();
        logoutBtn = new javax.swing.JButton();
        filepanel = new javax.swing.JPanel();
        delBtn = new javax.swing.JButton();
        addressField = new javax.swing.JTextField();
        serverLabel = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(700, 222));

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(null);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dropclient.DropClientApp.class).getContext().getResourceMap(DropClientView.class);
        unamelabel.setText(resourceMap.getString("unamelabel.text")); // NOI18N
        unamelabel.setName("unamelabel"); // NOI18N
        jPanel1.add(unamelabel);
        unamelabel.setBounds(150, 80, 48, 20);

        upasslabel.setText(resourceMap.getString("upasslabel.text")); // NOI18N
        upasslabel.setName("upasslabel"); // NOI18N
        jPanel1.add(upasslabel);
        upasslabel.setBounds(150, 120, 46, 20);

        unamefield.setText(resourceMap.getString("unamefield.text")); // NOI18N
        unamefield.setName("unamefield"); // NOI18N
        jPanel1.add(unamefield);
        unamefield.setBounds(220, 80, 146, 20);

        loginBtn.setText(resourceMap.getString("loginBtn.text")); // NOI18N
        loginBtn.setName("loginBtn"); // NOI18N
        loginBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                loginBtnMouseClicked(evt);
            }
        });
        jPanel1.add(loginBtn);
        loginBtn.setBounds(310, 150, 57, 23);

        upassfield.setText(resourceMap.getString("upassfield.text")); // NOI18N
        upassfield.setName("upassfield"); // NOI18N
        jPanel1.add(upassfield);
        upassfield.setBounds(220, 120, 146, 20);

        folderlabel.setText(resourceMap.getString("folderlabel.text")); // NOI18N
        folderlabel.setName("folderlabel"); // NOI18N
        jPanel1.add(folderlabel);
        folderlabel.setBounds(20, 40, 59, 20);

        foldernamefield.setEditable(false);
        foldernamefield.setText(resourceMap.getString("foldernamefield.text")); // NOI18N
        foldernamefield.setName("foldernamefield"); // NOI18N
        jPanel1.add(foldernamefield);
        foldernamefield.setBounds(90, 40, 200, 20);

        browseBtn.setText(resourceMap.getString("browseBtn.text")); // NOI18N
        browseBtn.setName("browseBtn"); // NOI18N
        browseBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                browseBtnMouseClicked(evt);
            }
        });
        jPanel1.add(browseBtn);
        browseBtn.setBounds(300, 40, 80, 23);

        syncBtn.setText(resourceMap.getString("syncBtn.text")); // NOI18N
        syncBtn.setName("syncBtn"); // NOI18N
        syncBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                syncBtnMouseClicked(evt);
            }
        });
        jPanel1.add(syncBtn);
        syncBtn.setBounds(170, 190, 200, 23);

        logoutBtn.setText(resourceMap.getString("logoutBtn.text")); // NOI18N
        logoutBtn.setName("logoutBtn"); // NOI18N
        logoutBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                logoutBtnMouseClicked(evt);
            }
        });
        jPanel1.add(logoutBtn);
        logoutBtn.setBounds(30, 190, 65, 23);

        filepanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("filepanel.border.title"))); // NOI18N
        filepanel.setName("filepanel"); // NOI18N

        javax.swing.GroupLayout filepanelLayout = new javax.swing.GroupLayout(filepanel);
        filepanel.setLayout(filepanelLayout);
        filepanelLayout.setHorizontalGroup(
            filepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 338, Short.MAX_VALUE)
        );
        filepanelLayout.setVerticalGroup(
            filepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 73, Short.MAX_VALUE)
        );

        jPanel1.add(filepanel);
        filepanel.setBounds(20, 80, 350, 100);

        delBtn.setText(resourceMap.getString("delBtn.text")); // NOI18N
        delBtn.setName("delBtn"); // NOI18N
        delBtn.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                delBtnMouseClicked(evt);
            }
        });
        delBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delBtnActionPerformed(evt);
            }
        });
        jPanel1.add(delBtn);
        delBtn.setBounds(300, 10, 80, 23);

        addressField.setText(resourceMap.getString("addressField.text")); // NOI18N
        addressField.setName("addressField"); // NOI18N
        jPanel1.add(addressField);
        addressField.setBounds(90, 10, 200, 20);

        serverLabel.setText(resourceMap.getString("serverLabel.text")); // NOI18N
        serverLabel.setName("serverLabel"); // NOI18N
        jPanel1.add(serverLabel);
        serverLabel.setBounds(20, 10, 50, 20);

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(dropclient.DropClientApp.class).getContext().getActionMap(DropClientView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 246, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void ShowHome() {
        unamelabel.setVisible(false);
        upasslabel.setVisible(false);
        unamefield.setVisible(false);
        upassfield.setVisible(false);
        loginBtn.setVisible(false);
        folderlabel.setVisible(true);
        foldernamefield.setVisible(true);
        foldernamefield.setText("");
        //addressField.setVisible(true);
        //addressField.setText("");
        browseBtn.setVisible(true);
        syncBtn.setVisible(true);
        logoutBtn.setVisible(true);
        //serverLabel.setVisible(true);
        //delBtn.setVisible(true);
    }

    private void HideHome() {
        unamelabel.setVisible(true);
        upasslabel.setVisible(true);
        unamefield.setVisible(true);
        unamefield.setText("");
        upassfield.setVisible(true);
        upassfield.setText("");
        loginBtn.setVisible(true);
        folderlabel.setVisible(false);
        foldernamefield.setVisible(false);
        //addressField.setVisible(false);
        browseBtn.setVisible(false);
        syncBtn.setVisible(false);
        logoutBtn.setVisible(false);
        filepanel.setVisible(false);
        //serverLabel.setVisible(false);
        //delBtn.setVisible(false);
    }

    private void loginBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_loginBtnMouseClicked
        // TODO add your handling code here:
        //ShowHome();
        //DropClientApp.getApplication().user_id = "1";
        //return;

        String username = this.unamefield.getText();
        String password = this.upassfield.getText();
        if (!username.equals("") && !password.equals("") && !DropClientApp.getApplication().serverAddress.equals("")) {
            //prosedur login
            /* buat tes login */
            /*DropClientApp app = DropClientApp.getApplication();
            app.user_id = "1";
            JOptionPane.showMessageDialog(mainPanel, "Login Berhasil");
            ShowHome();*/
            /* selesai tes login */
            try {
                HttpURLConnection conn = (HttpURLConnection) new URL("http://"+DropClientApp.getApplication().serverAddress+"/progin-1/tugas2/index.php/home/applogin").openConnection();
                conn.setRequestMethod("POST");

                conn.setDoOutput(true);
                OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
                out.write("username=" + username + "&password=" + password);
                out.flush();

                BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String line;
                if ((line = reader.readLine()) != null) {
                    System.out.println(line);
                    if (line.equals("failed")) {
                        JOptionPane.showMessageDialog(mainPanel, "Login gagal");
                    }
                    else {
                        //user_id = line;
                        DropClientApp app = DropClientApp.getApplication();
                        app.user_id = line;
                        System.out.println(app.user_id);
                        JOptionPane.showMessageDialog(mainPanel, "Login Berhasil");
                        ShowHome();
                    }
                }
                reader.close();
            } catch (IOException ex) {
                Logger.getLogger(DropClientView.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(mainPanel, "Username, Password dan alamat server harus diisi");
        }
    }//GEN-LAST:event_loginBtnMouseClicked

    private void browseBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_browseBtnMouseClicked
        // TODO add your handling code here:
        //int result;
        String choosertitle = "";

        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle(choosertitle);
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        //
        // disable the "All files" option.
        //
        chooser.setAcceptAllFileFilterUsed(false);
        //
        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            System.out.println("getCurrentDirectory(): "+ chooser.getCurrentDirectory());
            System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
            
            DropClientApp app = DropClientApp.getApplication();
            app.curpath = chooser.getSelectedFile().toString();
            System.out.println(app.curpath);
            this.foldernamefield.setText(app.curpath);
            showContentDir(app.curpath);
        } else {
            System.out.println("No Selection ");
        }
    }//GEN-LAST:event_browseBtnMouseClicked

    private void showContentDir(String dirpath) {
        File dir = new File(dirpath);
        File[] files = dir.listFiles();
        filepanel.removeAll();
        filepanel.setLayout(new GridLayout(files.length, 1));
        //CheckboxGroup cbg = new CheckboxGroup();
        for (File f : files) {
            if (f.isFile())
                filepanel.add(new Checkbox(f.getName()));
        }
        filepanel.updateUI();
        filepanel.setVisible(true);
    }

    private void deleteFiles(){
        String path = DropClientApp.getApplication().curpath;
        File dir = new File(path);
        File[] files = dir.listFiles();

        if (filepanel.getComponentCount()!=0) {
            Checkbox[] cblist = new Checkbox[filepanel.getComponentCount()];
            for (int i=0; i<cblist.length; i++) {
                Checkbox cb = (Checkbox) filepanel.getComponent(i);
                cblist[i] = cb;
            }
            for (Checkbox delcb : cblist) {
                if (delcb.getState()) {
                    // cari file di folder
                    for (File f : files) {
                        if (f.getName().equals(delcb.getLabel())) {
                            // delete file
                            if (!f.exists()) {
                                throw new IllegalArgumentException("Delete: no such file or directory: " + delcb.getLabel());
                            }

                            if (!f.canWrite()) {
                                throw new IllegalArgumentException("Delete: write protected: " + delcb.getLabel());
                            }

                            // If it is a directory, make sure it is empty
                            if (f.isDirectory()) {
                                String[] filesdir = f.list();
                                if (filesdir.length > 0) {
                                    throw new IllegalArgumentException("Delete: directory not empty: " + delcb.getLabel());
                                }
                            }

                            // Attempt to delete it
                            boolean success = f.delete();

                            if (!success) {
                                throw new IllegalArgumentException("Delete: deletion failed");
                            } else {
                                System.out.println("File berhasil dihapus");
                            }
                        }
                    }
                }
            }
        }
    }

    private java.util.Timer syncTimer = null;

    private void syncBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_syncBtnMouseClicked
        if (!DropClientApp.getApplication().curpath.equals("") && !DropClientApp.getApplication().serverAddress.equals("")) {
            syncTimer = new java.util.Timer();
            syncTimer.scheduleAtFixedRate(new SyncTask(DropClientApp.getApplication().curpath), 0, 10000);
        }
        else {
            JOptionPane.showMessageDialog(mainPanel, "Isi alamat server dan folder sinkronisasi terlebih dahulu");
        }
    }//GEN-LAST:event_syncBtnMouseClicked

    private void logoutBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoutBtnMouseClicked
        // TODO add your handling code here:
        HideHome();
        if (syncTimer != null)
            syncTimer.cancel();
    }//GEN-LAST:event_logoutBtnMouseClicked

    private void delBtnMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_delBtnMouseClicked
        // TODO add your handling code here:
        //deleteFiles();
        
    }//GEN-LAST:event_delBtnMouseClicked

    private void delBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delBtnActionPerformed
        // TODO add your handling code here:
        if (!addressField.getText().equals("")) {
            JOptionPane.showMessageDialog(mainPanel, "Server diset pada : " + addressField.getText());
            DropClientApp.getApplication().serverAddress = addressField.getText();
        }
}//GEN-LAST:event_delBtnActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField addressField;
    private javax.swing.JButton browseBtn;
    private javax.swing.JButton delBtn;
    private javax.swing.JPanel filepanel;
    private javax.swing.JLabel folderlabel;
    private javax.swing.JTextField foldernamefield;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton loginBtn;
    private javax.swing.JButton logoutBtn;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel serverLabel;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JButton syncBtn;
    private javax.swing.JTextField unamefield;
    private javax.swing.JLabel unamelabel;
    private javax.swing.JPasswordField upassfield;
    private javax.swing.JLabel upasslabel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
